package com.step.web;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.besjon.pojo.Dlt;
import com.cp.LetoUtil;

@RestController
@RequestMapping("index")
public class IndexController {
	
	@RequestMapping("demo")
	public String demo(String path) {
		
		return LetoUtil.getNew(null);
	}
	
	
	//"02#07#11#16#18"
	private static final String[] mys = {"02#07#11#16#18","01#05","01#06","05#06"};
	
	@RequestMapping("demo2")
	public String demo2(String path) {
		String last = Netutil.fromFile(path);
		JSONArray jarr = JSON.parseArray(last);
		if (null != jarr) {
			JSONObject jobj = (JSONObject)jarr.get(0);
			if (jobj != null) {
				Dlt dlt = jobj.getObject("dlt", Dlt.class);
				StringBuilder sd = new StringBuilder();
				sd.append(dlt.getTerm()).append("=>");
				sd.append(Leto.compute(mys[0], mys[1], dlt.getNumberCode()));
				sd.append(Leto.compute(mys[0], mys[2], dlt.getNumberCode()));
				sd.append(Leto.compute(mys[0], mys[3], dlt.getNumberCode()));
				return sd.toString();
			}
		}
		return null;
	}
	
	public static void main(String[] args) {
		String last = Netutil.fromFile("leto.txt");
		JSONArray jarr = JSON.parseArray(last);
		if (null != jarr) {
			JSONObject jobj = (JSONObject)jarr.get(0);
			if (jobj != null) {
				Dlt dlt = jobj.getObject("dlt", Dlt.class);
				StringBuilder sd = new StringBuilder();
				sd.append(Leto.compute(mys[0], mys[1], dlt.getNumberCode()));
				sd.append(Leto.compute(mys[0], mys[2], dlt.getNumberCode()));
				sd.append(Leto.compute(mys[0], mys[3], dlt.getNumberCode()));
				System.err.println(sd.toString());
			}
		}
	
	}
	
}
